import dotenv from "dotenv";
dotenv.config([".env"]);

import Koa from "koa";
import ai from "./module/ai.js";
import rag from "./module/rag.js";
// import { sendMessage } from "./module/ragModule.js";

import { sendMessage } from "./module/weater.js";
const app = new Koa();

app.use(async (ctx) => {
  const time = Date.now();
  const queryMessage = ctx.query.message;
  // const result = await ai.sendMessage(
  //     {
  //         message: ctx.query.message,
  //     },
  //     null,
  //     (chunk) => {
  //         console.log(chunk);
  //     }
  // );
  const result = await sendMessage(queryMessage);
  console.log("exec time is:", Date.now() - time);
  ctx.body = result;
});

app.listen(3000).addListener("listening", () => {
  console.log("---> smart 服务启动成功...");
});
